/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.File;

/**
 * <p>Project: jse2302 - DirDemo
 * <p>Powered by webrx On 2023-06-26 17:30:46
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class DirDemo {
    public static void main(String[] args) {
        //File dir = new File("user/abc/upload/goods");
        //System.out.println(dir.isDirectory());
        //System.out.println(dir.exists());

        //建立空目录 ,递归建立多级目录
        //dir.mkdir();
        //dir.mkdirs();

        //File uu = new File("user/abc/upload");
        //uu.deleteOnExit(); 只能空目录

        //读取目录
        String path = "D:\\0531\\javase\\jse2302";
        File root = new File(path);
        //System.out.println(root.isDirectory());
        //System.out.println(root.isFile());
        //System.out.println(root.exists());

        File[] fs = root.listFiles();
        for (File f : fs) {
            //System.out.println(f.getName()+(f.isFile()?"文件":"目录"));
            String fn = f.getName();
            String t = f.isFile() ? "文件" : "目录";
            //System.out.println(fn + "[" + t + "]");
            System.out.printf("%s [%s]%n", fn, t);
        }

    }
}
